package org.hegang.design.first.abstractfactorypattern;

import org.hegang.design.common.CommonFields;

/**
 * @ClassName AbstractFactoryPatternMain
 * @Describe: 抽象工厂模式
 * @Author: gang.he
 * @Email: SmileSkylife@outlook.com
 * @Date: Created in 22:54 2019/6/28
 * @Modified By:
 * @Version V1.0
 */
public class AbstractFactoryPatternMain {
    public static void main(String[] args) {
        //获取形状工厂
        AbstractFactory shapeFactory = FactoryProducter.getFactory(CommonFields.SHAPE);
        Shape rectangle = shapeFactory.getShape(CommonFields.RECTANGLE);
        rectangle.draw();
        Shape square = shapeFactory.getShape(CommonFields.SQUARE);
        square.draw();
        Shape circle = shapeFactory.getShape(CommonFields.CIRCLE);
        circle.draw();

        System.out.println("=============分割线===============");

        //获取颜色工厂
        AbstractFactory colorFactory = FactoryProducter.getFactory(CommonFields.COLOR);
        Color red = colorFactory.getColor(CommonFields.RED);
        red.fill();
        Color green = colorFactory.getColor(CommonFields.GREEN);
        green.fill();
        Color blue = colorFactory.getColor(CommonFields.BLUE);
        blue.fill();

        System.out.println("###############################");
        Product huaweiProduct = SuperFactory.getHuaweiCompany();
        Mobile huaweiMobile = huaweiProduct.getMobile();
        huaweiMobile.start();
        huaweiMobile.call();
        huaweiMobile.send();
        huaweiMobile.send();

        Product xiaoMiProduct = SuperFactory.getXiaoMiCompany();
        Mobile xiaoMiMobile = xiaoMiProduct.getMobile();
        xiaoMiMobile.start();
        xiaoMiMobile.call();
        xiaoMiMobile.send();
        xiaoMiMobile.send();
    }
}
